const Ctoaes = require('./src/ctoaes');
const API_DOMAIN = 'https://api-cto.go8.workers.dev/p/'

const DB_HASH = "evlon-db-cdndb-p";
const DB_HASH_IV = "987123654456abcd";

function enc(key){
    let ctoaes = new Ctoaes();

    let jsonObj = {
        p: key,
        t: new Date().valueOf()
    };

    let token = ctoaes.encryption_utf82hex(JSON.stringify(jsonObj), Buffer.from(DB_HASH, "utf8"), Buffer.from(DB_HASH_IV, "utf8"))
    return API_DOMAIN + encodeURIComponent(token) 
}

 
console.log(enc("71a5ccecd4419dbf"));